package controllers

import (
	"cld-quick-cli/com"
	"cld-quick-cli/logic"
	"github.com/gin-gonic/gin"
)

// GetAllCommunityList 查询全部的社区信息 [{community_id,community_name}]
func GetAllCommunityList() func(ctx *gin.Context) {
	return func(ctx *gin.Context) {
		// 1.不需要查询参数，直接查！
		listLogic, err := logic.GetCommunityListLogic()
		if err != nil {
			com.ResponseData(ctx, com.CodeFailed, err.Error())
			return
		}
		com.ResponseData(ctx, com.CodeSuccess, listLogic)
	}
}

// GetCommunityDetails 查询全部的社区信息 [{community_id,community_name}]
func GetCommunityDetails() func(ctx *gin.Context) {
	return func(ctx *gin.Context) {
		// 1.查询参数 /:id
		param := ctx.Param("id")
		detailsLogic, err := logic.GetCommunityDetailsLogic(&param)
		if err != nil {
			com.ResponseData(ctx, com.CodeFailed, err.Error())
			return
		}
		com.ResponseData(ctx, com.CodeSuccess, detailsLogic)
	}
}
